/***************************************************************************
 * The Open Armory API is a project to retrieve World of Warcraft(R) 
 * related XML data from The Armory.
 * 
 * The data retrieved via the Open Armory API from The Armory is 
 * proprietary to Blizzard Entertainment, Inc(R).
 * *************************************************************************
 * Copyright (C) 2009 - 2010 Tedla M.B. Brandsema
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ***************************************************************************/
package net.openarmory.core.config;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.log4j.Logger;

// TODO: Auto-generated Javadoc
/**
 * <p>
 * The Class <b>ConfigurationProperties</b> is a singleton that sets the
 * properties as defined in the <i>configuration.properties</i> file.
 * </p>
 */
public final class ConfigurationProperties {

	/** The log. */
	private static final Logger LOG = Logger
			.getLogger(ConfigurationProperties.class);

	/** The PROPERTIES FILE NAME. */
	private static final String PROPERTIES_FILE_NAME = "configuration.properties";

	/** The PROPERTY OUTPUT DIR. */
	private static final String PROPERTY_OUTPUT_DIR = "output.directory";

	/** The PROPERTY PROXY. */
	private static final String PROPERTY_PROXY = "proxy";

	/** The PROPERTY PROXY HOST. */
	private static final String PROPERTY_PROXY_HOST = "proxy.host";

	/** The PROPERTY PROXY PORT. */
	private static final String PROPERTY_PROXY_PORT = "proxy.port";

	/** The PROPERTY USER AGENT. */
	private static final String PROPERTY_USER_AGENT = "user.agent";

	/** The PROPERTY ARMORY URL EU. */
	private static final String PROPERTY_ARMORY_URL_EU = "armory.url.eu";

	/** The PROPERTY ARMORY URL US. */
	private static final String PROPERTY_ARMORY_URL_US = "armory.url.us";

	/** The Constant PROPERTY_CHARACTER_NAME_URL_VARIABLE. */
	private static final String PROPERTY_CHARACTER_NAME_URL_VARIABLE = "url.variable.charactername";

	/** The Constant PROPERTY_REALM_URL_VARIABLE. */
	private static final String PROPERTY_REALM_URL_VARIABLE = "url.variable.realm";

	/** The Constant PROPERTY_GUILD_URL_VARIABLE. */
	private static final String PROPERTY_GUILD_URL_VARIABLE = "url.variable.guild";

	/** The Constant PROPERTY_ITEM_URL_VARIABLE. */
	private static final String PROPERTY_ITEM_URL_VARIABLE = "url.variable.item";

	/** The Constant PROPERTY_SLOT_URL_VARIABLE. */
	private static final String PROPERTY_SLOT_URL_VARIABLE = "url.variable.slot";

	/** The Constant PROPERTY_QUERY_STRING_SEPERATOR. */
	private static final String PROPERTY_QUERY_STRING_SEPERATOR = "url.query.seperator.string";

	/** The Constant PROPERTY_QUERY_VARIABLE_SEPERATOR. */
	private static final String PROPERTY_QUERY_VARIABLE_SEPERATOR = "url.query.seperator.variable";

	/** The PROPERTY CHARACTER PROFILE. */
	private static final String PROPERTY_CHARACTER_PROFILE = "character.profile.filename";

	/** The PROPERTY CHARACTER TALENTS. */
	private static final String PROPERTY_CHARACTER_TALENTS = "character.talents.and.glyphs.filename";

	/** The PROPERTY CHARACTER REPUTATION. */
	private static final String PROPERTY_CHARACTER_REPUTATION = "character.reputation.filename";

	/** The PROPERTY CHARACTER ACHIEVEMENTS. */
	private static final String PROPERTY_CHARACTER_ACHIEVEMENTS = "character.achievements.filename";

	/** The PROPERTY CHARACTER STATISTICS. */
	private static final String PROPERTY_CHARACTER_STATISTICS = "character.statistics.filename";

	/** The PROPERTY CHARACTER ARENA. */
	private static final String PROPERTY_CHARACTER_ARENA = "character.arena.filename";

	/** The PROPERTY CHARACTER ACTIVITYFEED. */
	private static final String PROPERTY_CHARACTER_ACTIVITY_FEED = "character.activityfeed.filename";

	/** The PROPERTY GUILD ROSTER. */
	private static final String PROPERTY_GUILD_ROSTER = "guild.roster.filename";

	/** The PROPERTY GUILD STATS. */
	private static final String PROPERTY_GUILD_STATS = "guild.stats.filename";

	/** The PROPERTY ITEM TOOLTIP. */
	private static final String PROPERTY_ITEM_TOOLTIP = "item.tooltip.filename";

	/** The PROPERTY ICON URL PATH. */
	private static final String PROPERTY_ICON_URL_PATH = "icon.url.path";

	/** The PROPERTY ICON SIZE 21. */
	private static final String PROPERTY_ICON_SIZE_21 = "icon.url.size.21";

	/** The PROPERTY ICON SIZE 43. */
	private static final String PROPERTY_ICON_SIZE_43 = "icon.url.size.43";

	/** The PROPERTY ICON SIZE 64. */
	private static final String PROPERTY_ICON_SIZE_64 = "icon.url.size.64";

	/** The PROPERTY ICON EXTENSION SMALL. */
	private static final String PROPERTY_ICON_EXT_SMALL = "icon.extension.small";

	/** The PROPERTY ICON EXTENSION LARGE. */
	private static final String PROPERTY_ICON_EXT_LARGE = "icon.extension.large";

	/** The PROPERTY PORTRAIT URL PATH. */
	private static final String PROPERTY_PORTRAIT_URL_PATH = "portrait.url.path";

	/** The PROPERTY PORTRAIT 80. */
	private static final String PROPERTY_PORTRAIT_80 = "portrait.url.level.80";

	/** The PROPERTY PORTRAIT 70. */
	private static final String PROPERTY_PORTRAIT_70 = "portrait.url.level.70";

	/** The PROPERTY PORTRAIT 60. */
	private static final String PROPERTY_PORTRAIT_60 = "portrait.url.level.60";

	/** The PROPERTY PORTRAIT DEFAULT. */
	private static final String PROPERTY_PORTRAIT_DEFAULT = "portrait.url.level.default";

	/** The PROPERTY PORTRAIT EXTENSION. */
	private static final String PROPERTY_PORTRAIT_EXT = "portrait.extension";

	/** The PROPERTY REALM STATUS URL. */
	private static final String PROPERTY_REALM_STATUS_URL = "realm.status.export.url";

	/** The PROPERTY REALM STATUS CSV NAME. */
	private static final String PROPERTY_REALM_STATUS_CSV_NAME = "realm.status.csv.name";

	/** The properties. */
	private final Properties properties;

	/** The instance. */
	private static ConfigurationProperties instance;

	/**
	 * Instantiates a new configuration properties.
	 * 
	 * @throws IOException
	 *             Signals that an I/O exception has occurred.
	 */
	private ConfigurationProperties() throws IOException {
		final InputStream streamIn = getClass().getClassLoader()
				.getResourceAsStream(PROPERTIES_FILE_NAME);
		// LOG.debug(ConfigurationProperties.class.getProtectionDomain()
		// .getCodeSource().getLocation().getPath());
		// InputStream streamIn = new FileInputStream(PROPERTIES_FILE_NAME);
		this.properties = new Properties();
		this.properties.load(streamIn);
	}

	/**
	 * Gets the single instance of ConfigurationProperties.
	 * 
	 * @return single instance of ConfigurationProperties
	 * 
	 * @throws IOException
	 *             Signals that an I/O exception has occurred.
	 */
	public static ConfigurationProperties getInstance() throws IOException {
		if (instance == null) {
			instance = new ConfigurationProperties();
			LOG.debug("Creating new configuration instance.");
		}
		return instance;
	}

	/**
	 * Gets the output dir.
	 * 
	 * @return the output dir
	 */
	public String getOutputDir() {
		return this.properties.getProperty(PROPERTY_OUTPUT_DIR);
	}

	/**
	 * Checks if a proxy is enabled.
	 * 
	 * @return true, if proxy is enabled
	 */
	public boolean isProxy() {
		return Boolean
				.parseBoolean(this.properties.getProperty(PROPERTY_PROXY));
	}

	/**
	 * Gets the proxy host.
	 * 
	 * @return the proxy host
	 */
	public String getProxyHost() {
		return this.properties.getProperty(PROPERTY_PROXY_HOST);
	}

	/**
	 * Gets the proxy port.
	 * 
	 * @return the proxy port
	 */
	public String getProxyPort() {
		return this.properties.getProperty(PROPERTY_PROXY_PORT);
	}

	/**
	 * Gets the user agent.
	 * 
	 * @return the user agent
	 */
	public String getUserAgent() {
		return this.properties.getProperty(PROPERTY_USER_AGENT);
	}

	/**
	 * Gets the armory url eu.
	 * 
	 * @return the armory url eu
	 */
	public String getArmoryUrlEu() {
		return this.properties.getProperty(PROPERTY_ARMORY_URL_EU);
	}

	/**
	 * Gets the armory url us.
	 * 
	 * @return the armory url us
	 */
	public String getArmoryUrlUs() {
		return this.properties.getProperty(PROPERTY_ARMORY_URL_US);
	}

	/**
	 * Gets the character name url variable.
	 * 
	 * @return the character name url variable
	 */
	public String getCharacterNameUrlVariable() {
		return this.properties
				.getProperty(PROPERTY_CHARACTER_NAME_URL_VARIABLE);
	}

	/**
	 * Gets the realm url variable.
	 * 
	 * @return the realm url variable
	 */
	public String getRealmUrlVariable() {
		return this.properties.getProperty(PROPERTY_REALM_URL_VARIABLE);
	}

	/**
	 * Gets the guild url variable.
	 * 
	 * @return the guild url variable
	 */
	public String getGuildUrlVariable() {
		return this.properties.getProperty(PROPERTY_GUILD_URL_VARIABLE);
	}

	/**
	 * Gets the item url variable.
	 * 
	 * @return the item url variable
	 */
	public String getItemUrlVariable() {
		return this.properties.getProperty(PROPERTY_ITEM_URL_VARIABLE);
	}

	/**
	 * Gets the slot url variable.
	 * 
	 * @return the slot url variable
	 */
	public String getSlotUrlVariable() {
		return this.properties.getProperty(PROPERTY_SLOT_URL_VARIABLE);
	}

	/**
	 * Gets the query string seperator.
	 * 
	 * @return the query string seperator
	 */
	public String getQueryStringSeperator() {
		return this.properties.getProperty(PROPERTY_QUERY_STRING_SEPERATOR);
	}

	/**
	 * Gets the query variable seperator.
	 * 
	 * @return the query variable seperator
	 */
	public String getQueryVariableSeperator() {
		return this.properties.getProperty(PROPERTY_QUERY_VARIABLE_SEPERATOR);
	}

	/**
	 * Gets the character profile filename.
	 * 
	 * @return the character profile filename
	 */
	public String getCharacterProfileFilename() {
		return this.properties.getProperty(PROPERTY_CHARACTER_PROFILE);
	}

	/**
	 * Gets the character talents filename.
	 * 
	 * @return the character talents filename
	 */
	public String getCharacterTalentsFilename() {
		return this.properties.getProperty(PROPERTY_CHARACTER_TALENTS);
	}

	/**
	 * Gets the character reputation filename.
	 * 
	 * @return the character reputation filename
	 */
	public String getCharacterReputationFilename() {
		return this.properties.getProperty(PROPERTY_CHARACTER_REPUTATION);
	}

	/**
	 * Gets the character achievements filename.
	 * 
	 * @return the character achievements filename
	 */
	public String getCharacterAchievementsFilename() {
		return this.properties.getProperty(PROPERTY_CHARACTER_ACHIEVEMENTS);
	}

	/**
	 * Gets the character statistics filename.
	 * 
	 * @return the character statistics filename
	 */
	public String getCharacterStatisticsFilename() {
		return this.properties.getProperty(PROPERTY_CHARACTER_STATISTICS);
	}

	/**
	 * Gets the character arena filename.
	 * 
	 * @return the character arena filename
	 */
	public String getCharacterArenaFilename() {
		return this.properties.getProperty(PROPERTY_CHARACTER_ARENA);
	}

	/**
	 * Gets the character arena filename.
	 * 
	 * @return the character arena filename
	 */
	public String getCharacterActivityFeedFilename() {
		return this.properties.getProperty(PROPERTY_CHARACTER_ACTIVITY_FEED);
	}

	/**
	 * Gets the guild roster filename.
	 * 
	 * @return the guild roster filename
	 */
	public String getGuildRosterFilename() {
		return this.properties.getProperty(PROPERTY_GUILD_ROSTER);
	}

	/**
	 * Gets the guild stats filename.
	 * 
	 * @return the guild stats filename
	 */
	public String getGuildStatsFilename() {
		return this.properties.getProperty(PROPERTY_GUILD_STATS);
	}

	/**
	 * Gets the item tooltip filename.
	 * 
	 * @return the item tooltip filename
	 */
	public String getItemTooltipFilename() {
		return this.properties.getProperty(PROPERTY_ITEM_TOOLTIP);
	}

	/**
	 * Gets the icon url path.
	 * 
	 * @return the icon url path
	 */
	public String getIconUrlPath() {
		return this.properties.getProperty(PROPERTY_ICON_URL_PATH);
	}

	/**
	 * Gets the icon url size21.
	 * 
	 * @return the icon url size21
	 */
	public String getIconUrlSize21() {
		return this.properties.getProperty(PROPERTY_ICON_SIZE_21);
	}

	/**
	 * Gets the icon url size43.
	 * 
	 * @return the icon url size43
	 */
	public String getIconUrlSize43() {
		return this.properties.getProperty(PROPERTY_ICON_SIZE_43);
	}

	/**
	 * Gets the icon url size64.
	 * 
	 * @return the icon url size64
	 */
	public String getIconUrlSize64() {
		return this.properties.getProperty(PROPERTY_ICON_SIZE_64);
	}

	/**
	 * Gets the icon extension small.
	 * 
	 * @return the icon extension small
	 */
	public String getIconExtensionSmall() {
		return this.properties.getProperty(PROPERTY_ICON_EXT_SMALL);
	}

	/**
	 * Gets the icon extension large.
	 * 
	 * @return the icon extension large
	 */
	public String getIconExtensionLarge() {
		return this.properties.getProperty(PROPERTY_ICON_EXT_LARGE);
	}

	/**
	 * Gets the portrait url path.
	 * 
	 * @return the portrait url path
	 */
	public String getPortraitUrlPath() {
		return this.properties.getProperty(PROPERTY_PORTRAIT_URL_PATH);
	}

	/**
	 * Gets the portrait80.
	 * 
	 * @return the portrait80
	 */
	public String getPortrait80() {
		return this.properties.getProperty(PROPERTY_PORTRAIT_80);
	}

	/**
	 * Gets the portrait70.
	 * 
	 * @return the portrait70
	 */
	public String getPortrait70() {
		return this.properties.getProperty(PROPERTY_PORTRAIT_70);
	}

	/**
	 * Gets the portrait60.
	 * 
	 * @return the portrait60
	 */
	public String getPortrait60() {
		return this.properties.getProperty(PROPERTY_PORTRAIT_60);
	}

	/**
	 * Gets the portrait default.
	 * 
	 * @return the portrait default
	 */
	public String getPortraitDefault() {
		return this.properties.getProperty(PROPERTY_PORTRAIT_DEFAULT);
	}

	/**
	 * Gets the portrait extension.
	 * 
	 * @return the portrait extension
	 */
	public String getPortraitExtension() {
		return this.properties.getProperty(PROPERTY_PORTRAIT_EXT);
	}

	/**
	 * Gets the realm status url.
	 * 
	 * @return the realm status url
	 */
	public String getRealmStatusUrl() {
		return this.properties.getProperty(PROPERTY_REALM_STATUS_URL);
	}

	/**
	 * Gets the realm status csv name.
	 * 
	 * @return the realm status csv name
	 */
	public String getRealmStatusCSVName() {
		return this.properties.getProperty(PROPERTY_REALM_STATUS_CSV_NAME);
	}
}
